﻿
using Topics.Radical.Validation;

namespace Dexter.Domain.Model
{
	public partial class InboxMessage
	{
		public virtual void ValidateForSave ( ) {
			Ensure.That ( Id )
				.Named ( "Id" )
				.WithPreview ( ( v, e ) => Logger.Warn ( v.GetFullErrorMessage ( ), e ) )
				.Is ( 0 )
				.WithMessage ( "Invalid message Key" );

			Ensure.That ( this.Subject )
				.Named ( "Id" )
				.WithPreview ( ( v, e ) => Logger.Warn ( v.GetFullErrorMessage ( ), e ) )
				.IsNotNullNorEmpty (  )
				.WithMessage ( "Invalid message subject" );

			Ensure.That ( this.Message )
				.Named ( "Id" )
				.WithPreview ( ( v, e ) => Logger.Warn ( v.GetFullErrorMessage ( ), e ) )
				.IsNotNullNorEmpty ( )
				.WithMessage ( "Invalid message body" );

			Ensure.That ( this.Name )
				.Named ( "Id" )
				.WithPreview ( ( v, e ) => Logger.Warn ( v.GetFullErrorMessage ( ), e ) )
				.IsNotNullNorEmpty ( )
				.WithMessage ( "Invalid message Name" );

			Ensure.That ( this.Email )
				.Named ( "Id" )
				.WithPreview ( ( v, e ) => Logger.Warn ( v.GetFullErrorMessage ( ), e ) )
				.IsNotNullNorEmpty ( )
				.WithMessage ( "Invalid message email" );

		}

		public virtual void ValidateForDelete ( ) {
			Ensure.That ( Id )
				.Named ( "Id" )
				.WithPreview ( ( v, e ) => Logger.Warn ( v.GetFullErrorMessage ( ), e ) )
				.IsGreaterThen ( 0 )
				.WithMessage ( "Invalid message Key" );
		}
	}
}
